#!/bin/bash 

source ./test.cfg

DEBUG=0

if [ -z $1 ]; then
  NODE=msserver01a
else
  NODE=${APPLIANCE[$1]}
fi

if [ -z $2 ]; then
  ID=c00000001
  TOPIC=/APP/a01/CAR/${ID}
else
  ID=${CAR[$2]}
  TOPIC=/APP/${APP[$2]}/CAR/${ID}
fi

MESSAGES=$((${MESSAGES}/4))
RATE=$((${RATE}/4))

ENDPOINT=`/niagara/test/scripts/getclusterserverendpointport.py -c ${CLUSTER} -e SVT-CarsInternetEndpoint -a ${NODE}`

if [ ${DEBUG} -ne 0 ]; then
  echo CLUSTER=${CLUSTER}
  echo NODE=${NODE}
  echo ENDPOINT=${ENDPOINT}
  echo QOS=${QOS}
  echo MESSAGES=${MESSAGES}
  echo ID=${ID}
fi


echo java -Djavax.net.ssl.trustStore=${CACERTS} -Djavax.net.ssl.trustStorePassword=${PASSWORD} svt.mqtt.mq.MqttSample -mqtt 3.1.1 -i ${ID}_$1 -u ${ID} -p ${PW} -a publish -t ${TOPIC} -s ssl://${ENDPOINT} -n ${MESSAGES} -O -v -e true -sslProtocol ${PROTOCOL} -w ${RATE} -q ${QOS}
java -Djavax.net.ssl.trustStore=${CACERTS} -Djavax.net.ssl.trustStorePassword=${PASSWORD} svt.mqtt.mq.MqttSample -mqtt 3.1.1 -i ${ID}_$1 -u ${ID} -p ${PW} -a publish -t ${TOPIC} -s ssl://${ENDPOINT} -n ${MESSAGES} -O -v -e true -sslProtocol ${PROTOCOL} -w ${RATE} -q ${QOS}



